import { type OrderTyle, type CommentList, type Doctor, type DoctorList } from "@/types/consult";
import request from "@/utils/request";

const DICT_BASE_URL = "/doctors/search";

const DoctorAPI = {
  /**
   * 搜索医生数据
   *
   * @param input 输入框关键字
   * @returns 医生列表数据
   */
  searchDoctor(input: string) {
    return request<DoctorList | undefined>({
      url: DICT_BASE_URL + "?input=" + input,
      method: "GET",
    });
  },
  /**
   * 获取医生详情数据
   *
   * @param id 医生ID
   * @returns 医生详情数据
   */
  getDoctorInfo(id: string) {
    return request<Doctor | undefined>({
      url: DICT_BASE_URL + "/" + id,
      method: "GET",
    });
  },
  /**
   * 获取医生评论数据
   *
   * @param id 医生评论ID
   * @returns 医生评论数据
   */
  getComment(id: string) {
    return request<CommentList | undefined>({
      url: "/commits/" + id,
      method: "GET",
    });
  },
  /**
   * 获取订单数据
   *
   * @param order 订单类型
   * @returns 获取订单数据
   */
  getOrders(order: string) {
    return request<OrderTyle[] | undefined>({
      url: "/order/search?paymentType=" + order,
      method: "GET",
    });
  },

  /**
   * 添加订单
   *
   * @param order 订单数据
   * @returns 订单数据
   */
  addOrders(order: OrderTyle) {
    return request<OrderTyle | undefined>({
      url: "/order",
      method: "POST",
      data: order,
    });
  },
};

export default DoctorAPI;

export interface KnowledgePageQuery {
  pageNum: number;
  likeFlag: number;
}
